<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>WeakSet语法</title>
</head>
<body>
    <div></div>
    <div></div>
    <script>
        // 只可以添加引用类型，跟Set类型一样，不能有重复元素
        let hd = new WeakSet();
        hd.add(['xiasnn','xiaxia']);
        console.log(hd);

        let nodes = new WeakSet();
        let divs = document.querySelectorAll('div');
        divs.forEach(function (item) {
            // 添加元素
            nodes.add(item);
        });

        console.log(nodes.has(divs[0]));
        // 删除元素
        nodes.delete(divs[0]);
        console.log(nodes.has(divs[0]));
    </script>
</body>
</html>